package msu.ml.data.level2;

/**
 * The StaticData class contains information regarding
 * each volume coverage pattern.
 *
 * @author Reginald M Mead
 * @version 1.0
 */
public class StaticData
{

	/**
	 * Get the Fix Angle for the give volume
	 * coverage patern and scan number.
	 *
	 * @param pattern volume coverage pattern
	 * @param elevationNumber index of sweep in volume scan
	 * @return fix angle
	 */
	public static float getFixAngle(int pattern, int elevationNumber)
	{
		int fa = getVcpData(pattern, (3 * elevationNumber) - 1);
		return (float)fa / 8.0f * 180.0f / 4096.0f;
	}

	/**
	 * Get the pulse count for the given volume
	 * coverage pattern and scan number.
	 *
	 * @param pattern volume coverage pattern
	 * @param elevationNumber index of sweep in volume scan
	 * @return pulse count
	 */
	public static int getPulseCount(int pattern, int elevationNumber)
	{
		return getVcpData(pattern, (3 * elevationNumber));
	}

	/**
	 * Get the azimuth rate for the given volume
	 * coverage pattern and scan number.
	 *
	 * @param pattern volume coverage pattern
	 * @param elevationNumber index of sweep in volume scan
	 * @return azimuth rate
	 */
	public static float getAzimuthRate(int pattern, int elevationNumber)
	{
		int ar = getVcpData(pattern, (3 * elevationNumber) + 1);
		return (float)ar / 8.0f * 45.0f / 4096.0f;
	}

	/**
	 * Get the pulse width for the given volume
	 * coverage pattern and scan number.
	 *
	 * @param pattern volume coverage pattern
	 * @return pulse width
	 */
	public static float getPulseWidth(int pattern)
	{
		int pw = getVcpData(pattern, 1);
		return (float)pw / 299.792458f;
	}

	private static int getVcpData(int pattern, int index)
	{
		switch(pattern)
		{
			case 11: return vcp11[index];
			case 12: return vcp12[index];
			case 21: return vcp21[index];
			case 31:	return vcp31[index];
			case 32: return vcp32[index];
			case 121: return vcp121[index];
			case 300: return vcp300[index];
			default: return 0;
		}

	}

	static int[] vcp11 = {11,514,88,17,13600,88,0,14000,264,16,12664,264,0,14000,440,6,11736,608,6,24760,784,6,24760,952,10,12712,1128,10,12720,1368,0,18328,1584,0,18496,1824,0,18512,2184,0,18544,2552,0,18576,3040,0,18640,3552,0,18712};

	static int[] vcp12 = {12,514,91,15,15401,91,0,18204,164,15,15401,164,0,18204,237,15,15401,237,0,18204,328,3,19297,437,3,20393,564,3,20393,728,3,20393,928,3,20393,1165,0,20680,1456,0,20680,1820,0,21033,2276,0,20929,2840,0,20929,3550,0,20929};

	static int[] vcp21 = {21,514,88,28,8256,88,0,8272,264,28,8256,264,0,8272,440,8,7888,608,8,7888,784,8,8160,1096,12,8160,1800,0,10640,2656,0,10432,3552,0,10496};

	static int[] vcp31 = {31,516,88,63,3672,88,0,3688,272,63,3672,272,0,3688,456,63,3672,456,0,3688,640,0,3688,816,0,3688};

	static int[] vcp32 = {32,514,88,64,3616,88,0,3312,272,64,3616,272,0,3312,456,11,2960,640,11,2960,816,11,2960};

	static int[] vcp121 = {121,514,91,11,21336,91,0,21696,91,0,19952,91,0,15584,264,11,21336,264,0,21696,264,0,19952,264,0,15584,437,6,13985,437,0,19952,437,0,15584,610,6,15729,610,0,19952,610,0,15584,783,6,11872,783,0,21481,1092,6,14712,1802,0,21481,2658,0,21696,3550,0,21696};

	static int[] vcp300 = {300,514,88,28,8256,88,0,8272,440,8,8160,1800,0,10384};
}
